USE [CIMaPlanningTemp]
GO
DROP TABLE po_balances_versions
GO
CREATE TABLE po_balances_versions (
	balance_version_id int NULL,
	balance_id int NOT NULL,
	purchase_order_version_id int NOT NULL,
	amount decimal(18, 4) NOT NULL,
	CONSTRAINT PK_po_balances_versions PRIMARY KEY(
			balance_id ASC,
			purchase_order_version_id ASC
		)
)
GO
ALTER TABLE po_balances_versions WITH CHECK ADD CONSTRAINT FK_pbv_bv FOREIGN KEY([balance_version_id]) REFERENCES balances_versions (balance_version_id)
GO
ALTER TABLE po_balances_versions CHECK CONSTRAINT FK_pbv_bv
GO
ALTER TABLE po_balances_versions WITH CHECK ADD CONSTRAINT FK_pbv_b FOREIGN KEY([balance_id]) REFERENCES balances (balance_id)
GO
ALTER TABLE po_balances_versions CHECK CONSTRAINT FK_pbv_b
GO
ALTER TABLE po_balances_versions WITH CHECK ADD CONSTRAINT FK_pbv_pov FOREIGN KEY([purchase_order_version_id]) REFERENCES purchases_orders_versions (purchase_order_version_id)
GO
ALTER TABLE po_balances_versions CHECK CONSTRAINT FK_pbv_pov
GO